home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_pcdp / ada / defs.ada < prev    next >
Text File  |  1996-01-30  |  2KB  |  51 lines

  1. package Tuple_Defs is
  2.  
  3.   type Vector   is array(Positive range <>) of Integer;
  4.   type Int_Ptr  is access Integer;
  5.   type Char_Ptr is access Character;
  6.   type Bool_Ptr is access Boolean;
  7.   type Str_Ptr  is access String;
  8.   type Vec_Ptr  is access Vector;
  9.  
  10.   type Tuple_Types is (None, Ints, Chars, Bools, Strs, Vecs);
  11.   type Tuple_Element(Tuple_Type: Tuple_Types := None) is
  12.     record
  13.       case Tuple_Type is
  14.         when None => null;
  15.         when Ints  => I: Int_Ptr;
  16.         when Chars => C: Char_Ptr;
  17.         when Bools => B: Bool_Ptr;
  18.         when Strs  => S: Str_Ptr;
  19.         when Vecs  => V: Vec_Ptr;
  20.       end case;
  21.     end record;
  22.  
  23.   Null_Element: constant Tuple_Element := (Tuple_Type => None);
  24.   Formal_Int:   constant Tuple_Element := (Ints,  null);
  25.   Formal_Char:  constant Tuple_Element := (Chars, null);
  26.   Formal_Bool:  constant Tuple_Element := (Bools, null);
  27.   Formal_Str:   constant Tuple_Element := (Strs,  null);
  28.   Formal_Vec:   constant Tuple_Element := (Vecs,  null);
  29.  
  30.   type Tuples is array(1..4) of Tuple_Element;
  31.  
  32.   Null_Tuple: constant Tuples := (others => (Tuple_Type => None));
  33.  
  34.   function Int(I:  Integer)   return Tuple_Element;
  35.   function Char(C: Character) return Tuple_Element;
  36.   function Bool(B: Boolean)   return Tuple_Element;
  37.   function Str(S:  String)    return Tuple_Element;
  38.   function Vec(V:  Vector)    return Tuple_Element;
  39.  
  40.   function Int(T:  Tuples; Index: Integer) return Integer;
  41.   function Char(T: Tuples; Index: Integer) return Character;
  42.   function Bool(T: Tuples; Index: Integer) return Boolean;
  43.   function Str(T:  Tuples; Index: Integer) return String;
  44.   function Vec(T:  Tuples; Index: Integer) return Vector;
  45.  
  46.   function Create_Tuple(T1, T2, T3, T4: Tuple_Element := 
  47.        (Null_Element)) return Tuples;
  48.   function Match(T1, T2: Tuples) return Boolean;
  49.  
  50. end Tuple_Defs;
  51.